/*
 * ADN3080.h
 *
 *  Created on: 2017年7月28日
 *      Author: Case
 */

#ifndef CG_SRC_ADN3080_H_
#define CG_SRC_ADN3080_H_

#include "r_cg_macrodriver.h"

#define ADN_RST		PORT0.PODR.BIT.B0
#define ADN_NPD		PORT0.PODR.BIT.B1
#define Product_ID   	0x00
#define Motion 	     	0x02
#define  DX		     		0X03
#define  DY		  		    0X04
#define  SQUAL		    0x05
#define  Pixel_Sum	 	0x06
#define Configuration_bits	 		0x0a
#define Extended_Config      		0x0b
#define Frame_Period_Lower	 	0x10
#define Frame_Period_Uppe	 	0x11
#define	Motion_Clear	     		0x12
#define	Frame_Capture	     		0x13
#define	SROM_Enable		     	0x14
#define Frame_Period_Max_Bound_Lower	0x19
#define Frame_Period_Max_Bound_Upper   0x1a
#define Frame_Period_Min_Bound_Lower    0x1b
#define Frame_Period_Min_Bound_Upper    0x1c
#define Shutter_Max_Bound_Lower         	0x1d
#define Shutter_Max_Bound_Upper         	0x1e
#define  SROM_ID	         	 0x1f
#define	Pixel_Burst	         0x40
#define	Motion_Burst         0x50
#define	SROM_Load	         0x60
#define H  200 //毫米
#define	ADN_CS				 PORT3.PODR.BIT.B0

void ADNS3080_reset(void);
uint32_t SPI_RW(uint8_t byte);
uint8_t SPI_Write_Reg(uint8_t reg, uint8_t value);
char SPI_Read_Reg(uint8_t reg);
uint8_t SPI_Read_Buffer(uint8_t reg, uint8_t * pBuf, uint8_t bytes);
uint8_t SPI_Write_Buffers(uint8_t reg, uint8_t * pBuf, uint8_t bytes);

void ADN_Init(void) ;
void ADN_Write_srom(void);
void ADN_Configuration(void);
uint8_t read_busy(void);
void clear_motion(void);
uint16_t read_zhenlv(void);
void Read_Data_burst(void);
void read_pixel(void);
void read_pixel_burst(void);
int covter_int(char num);
void Read_ADNS3080(void);
void Burst_ADN3080(uint8_t reg, uint8_t *data);
#endif /* CG_SRC_ADN3080_H_ */
